package org.destiny.student.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.destiny.student.entity.Student;

//@Mapper 这里可以使用@Mapper注解，但是每个mapper都加注解比较麻烦，所以统一配置@MapperScan在扫描路径在application类中
public interface StudentMapper {

    @Select("SELECT * FROM student WHERE id = #{id}")
    Student queryStudentById(Long id);

    @Select("SELECT * FROM student")
    public List<Student> queryAllStudentList();

    @Insert("insert into student(user_name, age, school) values(#{user_name}, #{age}, #{school})")
    public Integer insertStudent(Student student);

    @Update("UPDATE student SET user_name = #{student.user_name},school = #{student.school} , age = #{student.age} WHERE id = #{id}")
    public Integer updateStudentById(@Param("id") Long id, @Param("student") Student student);

    @Delete("DELETE from student where id = #{id} ")
    public Integer deleteStudentById(Long id);
}
